//
//  LYCameraManager.h
//  CustomCamera
//
//  Created by SuJiang on 2018/4/2.
//  Copyright © 2018年 appscomm. All rights reserved.
//

#import <AVFoundation/AVFoundation.h>
#import "LYCameraPreviewView.h"

typedef NS_ENUM( NSInteger, LYCameraCaptureMode)
{
    LYCameraCaptureModePhoto = 0,
    LYCameraCaptureModeVideo = 1
};

typedef NS_ENUM(NSInteger, LYCameraSetupResult)
{
    LYCameraSetupResultSuccess,
    LYCameraSetupResultCameraNotAuthorized,
    LYCameraSetupResultSessionConfigurationFailed
};

@protocol LYCameraManagerDelegate<NSObject>

- (void) cameraSessionSetupError:(LYCameraSetupResult)result;
- (void) cameraSessionResumeFailed;
- (void) cameraSessionVideoFrame:(CGImageRef)frame;

@end


@interface LYCameraManager : NSObject

@property(nonatomic, strong) LYCameraPreviewView *previewView;
@property(nonatomic, weak) id<LYCameraManagerDelegate> delegate;

- (void) startSessionRunning;
- (void) stopSessionRunning;
- (void) resumeInterruptedSession;

- (instancetype) initWithMode:(LYCameraCaptureMode)mode;

- (void) switchToMode:(LYCameraCaptureMode)mode;

#pragma mark - 对焦
- (void) switchFocusMode:(AVCaptureFocusMode)mode;

/**
 改变焦距
 
 @param position 0-1
 */
- (void) setFocusLensPosition:(CGFloat)position;

#pragma mark - 曝光
/**
 设置曝光倾斜
 
 @param bias -8 ~ 8
 */
- (void) setExposureTargetBias:(CGFloat)bias;


#pragma mark - 动作
- (void) captureWithCallback:(void (^)(UIImage *image))handler;
- (void) captureAndSaveToAlbumWithCallback:(void (^)(UIImage *image))handler;

@end
